/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CargaSocio.java
 *
 * Created on Apr 19, 2011, 9:00:18 AM
 */

package forms;

import beans.Barrio;
import beans.Bebida;
import beans.Boliche;
import beans.MedioComunicacion;
import beans.Musica;
import beans.Profesion;
import beans.Socio;
import java.awt.Color;
import java.awt.Cursor;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import managers.ManagerSocios;
import util.PreferenciaListModel;

/**
 *
 * @author nMoncho
 */
public class CargaSocio extends javax.swing.JFrame {

    /** Creates new form CargaSocio */
    public CargaSocio() {
        gestor = new ManagerSocios();
        initComponents();
        inicializar();
    }

    public CargaSocio(Socio socio) {
        gestor = new ManagerSocios(socio);
        initComponents();
        inicializar();

        //Cargar datos de socio
        textLegajo.setText(socio.getLegajo());
        textNombre.setText(socio.getNombre());
        textApellido.setText(socio.getApellido());
        textTelefono.setText(socio.getTelefono());
        textDireccion.setText(socio.getDireccion());
        textEmail.setText(socio.getMail());
        checkAvisarCumples.setSelected(socio.getAvisarPorCumpleagnos().compareTo("Y") == 0);
        dateChooser.setDate(socio.getFechaNacimiento());
        if(socio.getSexo().compareTo("M") == 0)
            radioMasculino.setSelected(true);
        else
            radioFemenino.setSelected(true);
        
        ComboBoxModel cbm = comboBoliche.getModel();
        Boliche boliche;
        for (int i = 0; i < cbm.getSize(); i++) {
            boliche = (Boliche)cbm.getElementAt(i);
            if(boliche.equals(socio.getBoliche()))
                comboBoliche.setSelectedItem(boliche);
        }
        cbm = comboBarrio.getModel();
        Barrio barrio;
        for (int i = 0; i < cbm.getSize(); i++) {
            barrio = (Barrio)cbm.getElementAt(i);
            if(barrio.equals(socio.getBarrio()))
                comboBarrio.setSelectedItem(barrio);
        }
        cbm = comboProfesion.getModel();
        Profesion profesion;
        for (int i = 0; i < cbm.getSize(); i++) {
            profesion = (Profesion)cbm.getElementAt(i);
            if(profesion.equals(socio.getEstudio()))
                comboProfesion.setSelectedItem(profesion);
        }
    }

    private void inicializar(){
        //Grupo para los radios del sexo
        ButtonGroup bg = new ButtonGroup();
        bg.add(radioMasculino);
        bg.add(radioFemenino);
        radioMasculino.setSelected(true);

        registrarInputVerifiers();
        rellenarCombos();

        this.setLocation(100, 100);
    }

    private void registrarInputVerifiers(){
        textLegajo.setInputVerifier(new InputVerifier() {
            @Override
            public boolean verify(JComponent input) {
                JTextField tf = (JTextField)input;
                try{
                    int legajo = Integer.parseInt(tf.getText());
                    textLegajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
                    return true;
                }catch(Exception ex){
                    textLegajo.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
                }
                return false;
            }
        });
        textEmail.setInputVerifier(new InputVerifier() {
            @Override
            public boolean verify(JComponent input) {
                JTextField tf = (JTextField)input;
                if(tf.getText().length() == 0 || tf.getText().matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")){
                    textEmail.setBorder(javax.swing.BorderFactory.createEtchedBorder());
                    return true;
                }else {
                    textEmail.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
                    return false;
                }
                
            }
        });
    }

    private void rellenarCombos(){
        for(Boliche boliche : gestor.getBoliches())
            comboBoliche.addItem(boliche);

        Profesion profesion = new Profesion();
        profesion.setNombre("Seleccionar un estudio");
        profesion.setId(0);
        comboProfesion.addItem(profesion);
        for(Profesion profe : gestor.getProfesiones())
            comboProfesion.addItem(profe);

        Barrio barrio = new Barrio();
        barrio.setNombre("Seleccionar un barrio");
        barrio.setId(0);
        comboBarrio.addItem(barrio);
        for(Barrio barr : gestor.getBarrios())
            comboBarrio.addItem(barr);

        DefaultListModel dlm = null;
        dlm = (DefaultListModel)listaBebidas.getModel();
        for(Bebida bebida : gestor.getBebidas())
            dlm.addElement(bebida);
        dlm = (DefaultListModel)listaMedios.getModel();
        for(MedioComunicacion medio : gestor.getMedios())
            dlm.addElement(medio);
        dlm = (DefaultListModel)listaMusica.getModel();
        for(Musica musica : gestor.getMusica())
            dlm.addElement(musica);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTextField1 = new javax.swing.JTextField();
        botonCerrar = new javax.swing.JButton();
        panelTabulado = new javax.swing.JTabbedPane();
        panelDatos = new javax.swing.JPanel();
        panelDatosPersonales = new javax.swing.JPanel();
        labelNombre = new javax.swing.JLabel();
        textNombre = new javax.swing.JTextField();
        labelApellido = new javax.swing.JLabel();
        textApellido = new javax.swing.JTextField();
        radioMasculino = new javax.swing.JRadioButton();
        radioFemenino = new javax.swing.JRadioButton();
        labelSexo = new javax.swing.JLabel();
        dateChooser = new com.toedter.calendar.JDateChooser();
        labelNacimiento = new javax.swing.JLabel();
        labelProfesion = new javax.swing.JLabel();
        comboProfesion = new javax.swing.JComboBox();
        jSeparator2 = new javax.swing.JSeparator();
        labelDireccion = new javax.swing.JLabel();
        textDireccion = new javax.swing.JTextField();
        labelBarrio = new javax.swing.JLabel();
        comboBarrio = new javax.swing.JComboBox();
        labelTelefono = new javax.swing.JLabel();
        textTelefono = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        textEmail = new javax.swing.JTextField();
        botonSiguiente = new javax.swing.JButton();
        panelDatosSocio = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        textLegajo = new javax.swing.JTextField();
        labelLegajo = new javax.swing.JLabel();
        labelBoliche = new javax.swing.JLabel();
        comboBoliche = new javax.swing.JComboBox();
        labelRazon = new javax.swing.JLabel();
        comboRazon = new javax.swing.JComboBox();
        checkAvisarCumples = new javax.swing.JCheckBox();
        panelPreferencias = new javax.swing.JPanel();
        panelBebidas = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaBebidas = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaBebidasPreferidas = new javax.swing.JList();
        jLabel3 = new javax.swing.JLabel();
        botonAgregarBebida = new javax.swing.JButton();
        botonQuitarBebida = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        panelMusica = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        listaMusica = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        listaMusicaPreferida = new javax.swing.JList();
        botonAgregarMusica = new javax.swing.JButton();
        botonQuitarMusica = new javax.swing.JButton();
        panelMedios = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        listaMedios = new javax.swing.JList();
        jScrollPane8 = new javax.swing.JScrollPane();
        listaMediosPreferidos = new javax.swing.JList();
        botonAgregarMusica2 = new javax.swing.JButton();
        botonQuitarMusica2 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        botonSiguiente1 = new javax.swing.JButton();
        botonAnterior = new javax.swing.JButton();
        panelAmigos = new javax.swing.JPanel();
        panelDatosAmigo = new javax.swing.JPanel();
        labelNombreAmigo = new javax.swing.JLabel();
        textNombreAmigo = new javax.swing.JTextField();
        labelApellidoAmigo = new javax.swing.JLabel();
        textApellidoAmigo = new javax.swing.JTextField();
        labelTelefonoAmigo = new javax.swing.JLabel();
        textTelefonoAmigo = new javax.swing.JTextField();
        labelFechaAmigo = new javax.swing.JLabel();
        dateChooserAmigo = new com.toedter.calendar.JDateChooser();
        botonAgregarAmigo = new javax.swing.JButton();
        botonQuitarAmigo = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jScrollPane5 = new javax.swing.JScrollPane();
        tableAmigos = new javax.swing.JTable();
        labelAmigos = new javax.swing.JLabel();
        botonAnterior1 = new javax.swing.JButton();
        botonGuardar = new javax.swing.JButton();

        jTextField1.setText("jTextField1");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gestionar Socios");
        setIconImage(new ImageIcon(getClass().getResource("/resources/arrow-branch-bgr-16-ns.png")).getImage());

        botonCerrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-cross-16-ns.png"))); // NOI18N
        botonCerrar.setText("Cerrar");
        botonCerrar.setToolTipText("Hace click para cerrar la ventana");
        botonCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonCerrarActionPerformed(evt);
            }
        });

        panelDatosPersonales.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales"));

        labelNombre.setText("Nombre:");

        labelApellido.setText("Apellido:");

        radioMasculino.setText("Masculino");

        radioFemenino.setText("Femenino");
        radioFemenino.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radioFemeninoActionPerformed(evt);
            }
        });

        labelSexo.setText("Sexo:");

        labelNacimiento.setText("Fecha Nac.");

        labelProfesion.setText("Estudio:");

        labelDireccion.setText("Direccion:");

        labelBarrio.setText("Barrio:");

        labelTelefono.setText("Telefono:");

        jLabel1.setText("E-Mail:");

        botonSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-right-16.png"))); // NOI18N
        botonSiguiente.setText("Siguiente");
        botonSiguiente.setToolTipText("Hace click para continuar la carga/edicion");
        botonSiguiente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSiguienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDatosPersonalesLayout = new javax.swing.GroupLayout(panelDatosPersonales);
        panelDatosPersonales.setLayout(panelDatosPersonalesLayout);
        panelDatosPersonalesLayout.setHorizontalGroup(
            panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosPersonalesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelDatosPersonalesLayout.createSequentialGroup()
                        .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelApellido)
                            .addComponent(labelNombre)
                            .addComponent(labelNacimiento)
                            .addComponent(labelSexo)
                            .addComponent(labelProfesion))
                        .addGap(18, 18, 18)
                        .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelDatosPersonalesLayout.createSequentialGroup()
                                .addComponent(radioMasculino)
                                .addGap(18, 18, 18)
                                .addComponent(radioFemenino))
                            .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(comboProfesion, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(textApellido, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(textNombre, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(dateChooser, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 408, Short.MAX_VALUE)
                    .addGroup(panelDatosPersonalesLayout.createSequentialGroup()
                        .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelDireccion)
                            .addComponent(labelBarrio)
                            .addComponent(labelTelefono)
                            .addComponent(jLabel1))
                        .addGap(32, 32, 32)
                        .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(textEmail)
                            .addComponent(textDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
                            .addComponent(textTelefono)
                            .addComponent(comboBarrio, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 164, Short.MAX_VALUE))
                    .addComponent(botonSiguiente, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );

        panelDatosPersonalesLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboBarrio, textDireccion, textEmail, textTelefono});

        panelDatosPersonalesLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboProfesion, dateChooser, textApellido, textNombre});

        panelDatosPersonalesLayout.setVerticalGroup(
            panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosPersonalesLayout.createSequentialGroup()
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNombre)
                    .addComponent(textNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelApellido)
                    .addComponent(textApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelSexo)
                    .addComponent(radioFemenino)
                    .addComponent(radioMasculino))
                .addGap(14, 14, 14)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(dateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(labelNacimiento))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelProfesion)
                    .addComponent(comboProfesion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDireccion)
                    .addComponent(textDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBarrio)
                    .addComponent(comboBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelTelefono)
                    .addComponent(textTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelDatosPersonalesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                .addComponent(botonSiguiente))
        );

        panelDatosPersonalesLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboBarrio, textDireccion, textEmail, textTelefono});

        panelDatosPersonalesLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboProfesion, dateChooser, textApellido, textNombre});

        panelDatosSocio.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del Socio"));

        textLegajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        labelLegajo.setText("Legajo:");

        labelBoliche.setText("Boliche:");

        comboBoliche.setToolTipText("Selecciona el boliche al pertenecera el socio");

        labelRazon.setText("Motivo Socio:");

        comboRazon.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CONSUMIDOR", "CONVOCANTE", "RELEVANTE" }));

        checkAvisarCumples.setText("Avisar Cumpleaños");

        javax.swing.GroupLayout panelDatosSocioLayout = new javax.swing.GroupLayout(panelDatosSocio);
        panelDatosSocio.setLayout(panelDatosSocioLayout);
        panelDatosSocioLayout.setHorizontalGroup(
            panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosSocioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
                    .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(panelDatosSocioLayout.createSequentialGroup()
                            .addComponent(labelLegajo)
                            .addGap(18, 18, 18)
                            .addComponent(textLegajo))
                        .addGroup(panelDatosSocioLayout.createSequentialGroup()
                            .addComponent(labelBoliche)
                            .addGap(18, 18, 18)
                            .addComponent(comboBoliche, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(checkAvisarCumples, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(panelDatosSocioLayout.createSequentialGroup()
                            .addComponent(labelRazon)
                            .addGap(18, 18, 18)
                            .addComponent(comboRazon, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        panelDatosSocioLayout.setVerticalGroup(
            panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosSocioLayout.createSequentialGroup()
                .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelBoliche)
                    .addComponent(comboBoliche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLegajo)
                    .addComponent(textLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(panelDatosSocioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelRazon)
                    .addComponent(comboRazon, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(checkAvisarCumples)
                .addContainerGap(285, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout panelDatosLayout = new javax.swing.GroupLayout(panelDatos);
        panelDatos.setLayout(panelDatosLayout);
        panelDatosLayout.setHorizontalGroup(
            panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(panelDatosSocio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelDatosPersonales, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelDatosLayout.setVerticalGroup(
            panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(panelDatosSocio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panelDatosPersonales, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        panelTabulado.addTab("Datos del Socio", panelDatos);

        panelPreferencias.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        panelBebidas.setBorder(javax.swing.BorderFactory.createTitledBorder("Bebidas Preferidas"));

        listaBebidas.setModel(new DefaultListModel());
        listaBebidas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        listaBebidas.setToolTipText("Seleccion las bebidas preferidas");
        jScrollPane1.setViewportView(listaBebidas);

        listaBebidasPreferidas.setModel(gestor.getBebidaModel());
        listaBebidasPreferidas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane2.setViewportView(listaBebidasPreferidas);

        jLabel3.setText("Preferidas");

        botonAgregarBebida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-right-16.png"))); // NOI18N
        botonAgregarBebida.setToolTipText("Agregar bebida preferida");
        botonAgregarBebida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarBebidaActionPerformed(evt);
            }
        });

        botonQuitarBebida.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-left-16.png"))); // NOI18N
        botonQuitarBebida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonQuitarBebidaActionPerformed(evt);
            }
        });

        jLabel5.setText("Listado");

        javax.swing.GroupLayout panelBebidasLayout = new javax.swing.GroupLayout(panelBebidas);
        panelBebidas.setLayout(panelBebidasLayout);
        panelBebidasLayout.setHorizontalGroup(
            panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBebidasLayout.createSequentialGroup()
                .addGroup(panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelBebidasLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botonAgregarBebida, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botonQuitarBebida, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE))
                    .addGroup(panelBebidasLayout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(jLabel5)
                        .addGap(101, 101, 101)
                        .addComponent(jLabel3)))
                .addGap(70, 70, 70))
        );
        panelBebidasLayout.setVerticalGroup(
            panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelBebidasLayout.createSequentialGroup()
                .addGroup(panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelBebidasLayout.createSequentialGroup()
                        .addGap(71, 71, 71)
                        .addComponent(botonAgregarBebida, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(botonQuitarBebida, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(panelBebidasLayout.createSequentialGroup()
                        .addGroup(panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelBebidasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE))))
                .addContainerGap())
        );

        panelMusica.setBorder(javax.swing.BorderFactory.createTitledBorder("Musica Preferida"));

        listaMusica.setModel(new DefaultListModel());
        listaMusica.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane3.setViewportView(listaMusica);

        jLabel4.setText("Preferidas");

        jLabel2.setText("Listado");

        listaMusicaPreferida.setModel(gestor.getMusicaModel());
        jScrollPane4.setViewportView(listaMusicaPreferida);

        botonAgregarMusica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-right-16.png"))); // NOI18N
        botonAgregarMusica.setToolTipText("Agregar bebida preferida");
        botonAgregarMusica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarMusicaActionPerformed(evt);
            }
        });

        botonQuitarMusica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-left-16.png"))); // NOI18N
        botonQuitarMusica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonQuitarMusicaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelMusicaLayout = new javax.swing.GroupLayout(panelMusica);
        panelMusica.setLayout(panelMusicaLayout);
        panelMusicaLayout.setHorizontalGroup(
            panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMusicaLayout.createSequentialGroup()
                .addGroup(panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelMusicaLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botonAgregarMusica, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botonQuitarMusica, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
                    .addGroup(panelMusicaLayout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addComponent(jLabel2)
                        .addGap(95, 95, 95)
                        .addComponent(jLabel4)))
                .addGap(84, 84, 84))
        );
        panelMusicaLayout.setVerticalGroup(
            panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMusicaLayout.createSequentialGroup()
                .addGroup(panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelMusicaLayout.createSequentialGroup()
                        .addGroup(panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jLabel4))
                        .addGap(9, 9, 9)
                        .addGroup(panelMusicaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)))
                    .addGroup(panelMusicaLayout.createSequentialGroup()
                        .addGap(66, 66, 66)
                        .addComponent(botonAgregarMusica, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(botonQuitarMusica, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        panelMedios.setBorder(javax.swing.BorderFactory.createTitledBorder("Medios de Comunicacion Preferida"));

        listaMedios.setModel(new DefaultListModel());
        listaMedios.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane7.setViewportView(listaMedios);

        listaMediosPreferidos.setModel(gestor.getMediosModel());
        listaMediosPreferidos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane8.setViewportView(listaMediosPreferidos);

        botonAgregarMusica2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-right-16.png"))); // NOI18N
        botonAgregarMusica2.setToolTipText("Agregar bebida preferida");
        botonAgregarMusica2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarMusica2ActionPerformed(evt);
            }
        });

        botonQuitarMusica2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-left-16.png"))); // NOI18N
        botonQuitarMusica2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonQuitarMusica2ActionPerformed(evt);
            }
        });

        jLabel6.setText("Listado");

        jLabel7.setText("Preferidas");

        javax.swing.GroupLayout panelMediosLayout = new javax.swing.GroupLayout(panelMedios);
        panelMedios.setLayout(panelMediosLayout);
        panelMediosLayout.setHorizontalGroup(
            panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMediosLayout.createSequentialGroup()
                .addGroup(panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelMediosLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botonAgregarMusica2, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(botonQuitarMusica2, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(13, 13, 13)
                        .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
                    .addGroup(panelMediosLayout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(jLabel6)
                        .addGap(95, 95, 95)
                        .addComponent(jLabel7)))
                .addGap(69, 69, 69))
        );
        panelMediosLayout.setVerticalGroup(
            panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelMediosLayout.createSequentialGroup()
                .addGroup(panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addGap(9, 9, 9)
                .addGroup(panelMediosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelMediosLayout.createSequentialGroup()
                        .addComponent(botonAgregarMusica2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(botonQuitarMusica2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(42, 42, 42)))
                .addContainerGap())
        );

        botonSiguiente1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-right-16.png"))); // NOI18N
        botonSiguiente1.setText("Siguiente");
        botonSiguiente1.setToolTipText("Hace click para continuar la carga/edicion");
        botonSiguiente1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSiguiente1ActionPerformed(evt);
            }
        });

        botonAnterior.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-left-16.png"))); // NOI18N
        botonAnterior.setText("Anterior");
        botonAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAnteriorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelPreferenciasLayout = new javax.swing.GroupLayout(panelPreferencias);
        panelPreferencias.setLayout(panelPreferenciasLayout);
        panelPreferenciasLayout.setHorizontalGroup(
            panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPreferenciasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelPreferenciasLayout.createSequentialGroup()
                        .addComponent(panelMedios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 251, Short.MAX_VALUE)
                        .addComponent(botonAnterior)
                        .addGap(18, 18, 18)
                        .addComponent(botonSiguiente1))
                    .addGroup(panelPreferenciasLayout.createSequentialGroup()
                        .addComponent(panelBebidas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(panelMusica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83, Short.MAX_VALUE)))
                .addContainerGap())
        );

        panelPreferenciasLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {botonAnterior, botonSiguiente1});

        panelPreferenciasLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {panelBebidas, panelMedios, panelMusica});

        panelPreferenciasLayout.setVerticalGroup(
            panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPreferenciasLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelMusica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(panelBebidas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(panelMedios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(panelPreferenciasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(botonSiguiente1)
                        .addComponent(botonAnterior)))
                .addGap(25, 25, 25))
        );

        panelPreferenciasLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelBebidas, panelMedios, panelMusica});

        panelTabulado.addTab("Preferencias", panelPreferencias);

        panelDatosAmigo.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos del Amigo"));

        labelNombreAmigo.setText("Nombre:");

        labelApellidoAmigo.setText("Apellido:");

        labelTelefonoAmigo.setText("Telefono:");

        labelFechaAmigo.setText("Fecha Nac.:");

        botonAgregarAmigo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-check-16-ns.png"))); // NOI18N
        botonAgregarAmigo.setText("Agregar");
        botonAgregarAmigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarAmigoActionPerformed(evt);
            }
        });

        botonQuitarAmigo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-cross-16-ns.png"))); // NOI18N
        botonQuitarAmigo.setText("Quitar");
        botonQuitarAmigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonQuitarAmigoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelDatosAmigoLayout = new javax.swing.GroupLayout(panelDatosAmigo);
        panelDatosAmigo.setLayout(panelDatosAmigoLayout);
        panelDatosAmigoLayout.setHorizontalGroup(
            panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosAmigoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(botonAgregarAmigo)
                    .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(panelDatosAmigoLayout.createSequentialGroup()
                            .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(labelNombreAmigo)
                                .addComponent(labelApellidoAmigo)
                                .addComponent(labelTelefonoAmigo))
                            .addGap(22, 22, 22)
                            .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(textTelefonoAmigo)
                                .addComponent(textApellidoAmigo)
                                .addComponent(textNombreAmigo, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)))
                        .addGroup(panelDatosAmigoLayout.createSequentialGroup()
                            .addComponent(labelFechaAmigo)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(dateChooserAmigo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(18, 18, 18)
                .addComponent(botonQuitarAmigo)
                .addContainerGap(32, Short.MAX_VALUE))
        );

        panelDatosAmigoLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {botonAgregarAmigo, botonQuitarAmigo});

        panelDatosAmigoLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {dateChooserAmigo, textApellidoAmigo, textNombreAmigo, textTelefonoAmigo});

        panelDatosAmigoLayout.setVerticalGroup(
            panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelDatosAmigoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNombreAmigo)
                    .addComponent(textNombreAmigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelApellidoAmigo)
                    .addComponent(textApellidoAmigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelTelefonoAmigo)
                    .addComponent(textTelefonoAmigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelFechaAmigo)
                    .addComponent(dateChooserAmigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 53, Short.MAX_VALUE)
                .addGroup(panelDatosAmigoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonAgregarAmigo)
                    .addComponent(botonQuitarAmigo))
                .addContainerGap())
        );

        panelDatosAmigoLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {dateChooserAmigo, textApellidoAmigo, textNombreAmigo, textTelefonoAmigo});

        tableAmigos.setModel(gestor.getAmigosModel());
        tableAmigos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane5.setViewportView(tableAmigos);

        labelAmigos.setText("Lista de Amigos del Socios:");

        botonAnterior1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-direction-left-16.png"))); // NOI18N
        botonAnterior1.setText("Anterior");
        botonAnterior1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAnterior1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelAmigosLayout = new javax.swing.GroupLayout(panelAmigos);
        panelAmigos.setLayout(panelAmigosLayout);
        panelAmigosLayout.setHorizontalGroup(
            panelAmigosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAmigosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAmigosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelAmigosLayout.createSequentialGroup()
                        .addComponent(panelDatosAmigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelAmigosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelAmigos)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jSeparator3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 833, Short.MAX_VALUE)
                    .addComponent(botonAnterior1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        panelAmigosLayout.setVerticalGroup(
            panelAmigosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAmigosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAmigosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelAmigosLayout.createSequentialGroup()
                        .addComponent(labelAmigos)
                        .addGap(8, 8, 8)
                        .addComponent(jScrollPane5, 0, 0, Short.MAX_VALUE))
                    .addComponent(panelDatosAmigo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 147, Short.MAX_VALUE)
                .addComponent(botonAnterior1)
                .addContainerGap())
        );

        panelTabulado.addTab("Amigos", panelAmigos);

        botonGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-square-check-16-ns.png"))); // NOI18N
        botonGuardar.setText("Guardar");
        botonGuardar.setToolTipText("Hace click para guardar un socio");
        botonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonGuardarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(648, Short.MAX_VALUE)
                .addComponent(botonGuardar)
                .addGap(18, 18, 18)
                .addComponent(botonCerrar)
                .addContainerGap())
            .addComponent(panelTabulado, javax.swing.GroupLayout.DEFAULT_SIZE, 858, Short.MAX_VALUE)
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {botonCerrar, botonGuardar});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(panelTabulado, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botonCerrar)
                    .addComponent(botonGuardar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void radioFemeninoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioFemeninoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_radioFemeninoActionPerformed

    private void botonCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonCerrarActionPerformed
        int respuesta = JOptionPane.showConfirmDialog(this, "Los cambios no guardado se perderan.\n¿Realmente deseas cerrar esta ventana?", "Confimacion", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_NO_OPTION);
        if(respuesta == JOptionPane.YES_OPTION)
            this.dispose();
}//GEN-LAST:event_botonCerrarActionPerformed

    private void botonSiguienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSiguienteActionPerformed
        panelTabulado.setSelectedIndex(1);
    }//GEN-LAST:event_botonSiguienteActionPerformed

    private void botonSiguiente1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSiguiente1ActionPerformed
        panelTabulado.setSelectedIndex(2);
    }//GEN-LAST:event_botonSiguiente1ActionPerformed

    private void botonAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAnteriorActionPerformed
        panelTabulado.setSelectedIndex(0);
    }//GEN-LAST:event_botonAnteriorActionPerformed

    private void botonQuitarAmigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonQuitarAmigoActionPerformed
        quitarAmigo();
    }//GEN-LAST:event_botonQuitarAmigoActionPerformed

    private void botonAnterior1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAnterior1ActionPerformed
        panelTabulado.setSelectedIndex(1);
    }//GEN-LAST:event_botonAnterior1ActionPerformed

    private void botonAgregarBebidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarBebidaActionPerformed
        agregarBebida();
    }//GEN-LAST:event_botonAgregarBebidaActionPerformed

    private void botonQuitarBebidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonQuitarBebidaActionPerformed
        quitarBebida();
    }//GEN-LAST:event_botonQuitarBebidaActionPerformed

    private void botonAgregarMusicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarMusicaActionPerformed
        agregarMusica();
    }//GEN-LAST:event_botonAgregarMusicaActionPerformed

    private void botonQuitarMusicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonQuitarMusicaActionPerformed
        quitarMusica();
    }//GEN-LAST:event_botonQuitarMusicaActionPerformed

    private void botonAgregarMusica2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarMusica2ActionPerformed
        agregarMedio();
    }//GEN-LAST:event_botonAgregarMusica2ActionPerformed

    private void botonQuitarMusica2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonQuitarMusica2ActionPerformed
        quitarMedio();
    }//GEN-LAST:event_botonQuitarMusica2ActionPerformed

    private void botonAgregarAmigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarAmigoActionPerformed
        agregarAmigo();
    }//GEN-LAST:event_botonAgregarAmigoActionPerformed

    private void botonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonGuardarActionPerformed
        guardarSocio();
    }//GEN-LAST:event_botonGuardarActionPerformed

    private boolean validarDatos(){
        boolean valido = true;
        //Validar Datos personales
        String nombre = textNombre.getText().trim();
        if(nombre.length() <= 0){
            textNombre.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            valido = false;
        }else
            textNombre.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        String apellido = textApellido.getText().trim();
        if(apellido.length() <= 0){
            textApellido.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            valido = false;
        }else
            textApellido.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        String legajo = textLegajo.getText().trim();
        if(legajo.length() <= 0){
            textLegajo.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            valido = false;
        }else
            textLegajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        if(gestor.legajoInvalidoParaBoliche(legajo, (Boliche)comboBoliche.getSelectedItem())){
            textLegajo.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            valido = false;
        }else
            textLegajo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        if(textEmail.getText().length() > 0 && !textEmail.getText().matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")){
            textEmail.setBorder(javax.swing.BorderFactory.createLineBorder(Color.RED, 2));
            valido = false;
        }else
            textEmail.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        return valido;
    }

    private boolean verificarContactos(){
        int cantContactos = 0;
        if(textDireccion.getText().trim().length() > 0)
            cantContactos++;
        if(textTelefono.getText().trim().length() > 0)
            cantContactos++;
        if(textEmail.getText().trim().length() > 0)
            cantContactos++;

        if(cantContactos == 0){
            int respuesta = JOptionPane.showConfirmDialog(this, "No hay ningun dato de contacto cargado (direccion, telefono o mail).\n"
                    + "¿Estas seguro que NO deseas agregar ningun dato de contacto?", "Confirmacion", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_OPTION);

            if(respuesta == JOptionPane.YES_OPTION)
                return true;
            else
                return false;
        }else
            return true;
    }

    private void prepararDatos(){
        gestor.setCargarDatosCliente(
                (Boliche)comboBoliche.getSelectedItem(),
                textLegajo.getText().trim(),
                (String)comboRazon.getSelectedItem(),
                checkAvisarCumples.isSelected(),
                textNombre.getText().trim(),
                textApellido.getText().trim(),
                (radioMasculino.isSelected() ? "M" : "F"),
                dateChooser.getDate(),
                (Profesion)comboProfesion.getSelectedItem(),
                textDireccion.getText().trim(),
                (Barrio)comboBarrio.getSelectedItem(),
                textTelefono.getText().trim(),
                textEmail.getText().trim());
    }

    private void guardarSocio(){
        if(validarDatos()){
            if(verificarContactos()){
                prepararDatos();
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                boolean exito = gestor.guardarSocio();
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                if(exito)
                    JOptionPane.showMessageDialog(this, "Los cambios se guardaron exitosamente", "Exito", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_OPTION);
                else
                    JOptionPane.showMessageDialog(this, "Ocurrio un error tratando de guardar los datos.\nPor favor, revisa lo datos y volve a intentarlo.", "Error", JOptionPane.ERROR_MESSAGE+JOptionPane.YES_OPTION);
            }
        }else
            JOptionPane.showMessageDialog(this, "Existe datos faltantes o incorrectos. Revisa lo siguiente:\n"
                    + "1. El legado es obligatorio, y no puede repetirse en un mismo boliche.\n"
                    + "2. El nombre y el apellido son obligatorios.\n"
                    + "3. El email, en caso de cargalo, debe ser valido.\n"
                    + "Si algun cuadro de texto esta con borde rojo, signifia que es dato esta mal cargado", "Error en datos", JOptionPane.ERROR_MESSAGE+JOptionPane.YES_OPTION);
    }
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]){
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CargaSocio().setVisible(true);
            }
        });
    }

    private ManagerSocios gestor;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonAgregarAmigo;
    private javax.swing.JButton botonAgregarBebida;
    private javax.swing.JButton botonAgregarMusica;
    private javax.swing.JButton botonAgregarMusica2;
    private javax.swing.JButton botonAnterior;
    private javax.swing.JButton botonAnterior1;
    private javax.swing.JButton botonCerrar;
    private javax.swing.JButton botonGuardar;
    private javax.swing.JButton botonQuitarAmigo;
    private javax.swing.JButton botonQuitarBebida;
    private javax.swing.JButton botonQuitarMusica;
    private javax.swing.JButton botonQuitarMusica2;
    private javax.swing.JButton botonSiguiente;
    private javax.swing.JButton botonSiguiente1;
    private javax.swing.JCheckBox checkAvisarCumples;
    private javax.swing.JComboBox comboBarrio;
    private javax.swing.JComboBox comboBoliche;
    private javax.swing.JComboBox comboProfesion;
    private javax.swing.JComboBox comboRazon;
    private com.toedter.calendar.JDateChooser dateChooser;
    private com.toedter.calendar.JDateChooser dateChooserAmigo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel labelAmigos;
    private javax.swing.JLabel labelApellido;
    private javax.swing.JLabel labelApellidoAmigo;
    private javax.swing.JLabel labelBarrio;
    private javax.swing.JLabel labelBoliche;
    private javax.swing.JLabel labelDireccion;
    private javax.swing.JLabel labelFechaAmigo;
    private javax.swing.JLabel labelLegajo;
    private javax.swing.JLabel labelNacimiento;
    private javax.swing.JLabel labelNombre;
    private javax.swing.JLabel labelNombreAmigo;
    private javax.swing.JLabel labelProfesion;
    private javax.swing.JLabel labelRazon;
    private javax.swing.JLabel labelSexo;
    private javax.swing.JLabel labelTelefono;
    private javax.swing.JLabel labelTelefonoAmigo;
    private javax.swing.JList listaBebidas;
    private javax.swing.JList listaBebidasPreferidas;
    private javax.swing.JList listaMedios;
    private javax.swing.JList listaMediosPreferidos;
    private javax.swing.JList listaMusica;
    private javax.swing.JList listaMusicaPreferida;
    private javax.swing.JPanel panelAmigos;
    private javax.swing.JPanel panelBebidas;
    private javax.swing.JPanel panelDatos;
    private javax.swing.JPanel panelDatosAmigo;
    private javax.swing.JPanel panelDatosPersonales;
    private javax.swing.JPanel panelDatosSocio;
    private javax.swing.JPanel panelMedios;
    private javax.swing.JPanel panelMusica;
    private javax.swing.JPanel panelPreferencias;
    private javax.swing.JTabbedPane panelTabulado;
    private javax.swing.JRadioButton radioFemenino;
    private javax.swing.JRadioButton radioMasculino;
    private javax.swing.JTable tableAmigos;
    private javax.swing.JTextField textApellido;
    private javax.swing.JTextField textApellidoAmigo;
    private javax.swing.JTextField textDireccion;
    private javax.swing.JTextField textEmail;
    private javax.swing.JTextField textLegajo;
    private javax.swing.JTextField textNombre;
    private javax.swing.JTextField textNombreAmigo;
    private javax.swing.JTextField textTelefono;
    private javax.swing.JTextField textTelefonoAmigo;
    // End of variables declaration//GEN-END:variables

    private void agregarBebida() {
        Object[] bebidas = listaBebidas.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaBebidas.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaBebidasPreferidas.getModel();
        for(int i=0;i<bebidas.length;i++){
            dlm0.removeElement(bebidas[i]);
            dlm1.addElement(bebidas[i]);
        }
        listaBebidas.updateUI();
        listaBebidasPreferidas.updateUI();
    }

    private void quitarBebida() {
        Object[] bebidas = listaBebidasPreferidas.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaBebidas.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaBebidasPreferidas.getModel();
        for(int i=0;i<bebidas.length;i++){
            dlm1.removeElement(bebidas[i]);
            dlm0.addElement(bebidas[i]);
        }
        listaBebidas.updateUI();
        listaBebidasPreferidas.updateUI();
    }

    private void agregarMusica() {
        Object[] musica = listaMusica.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaMusica.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaMusicaPreferida.getModel();
        for(int i=0;i<musica.length;i++){
            dlm0.removeElement(musica[i]);
            dlm1.addElement(musica[i]);
        }
        listaMusica.updateUI();
        listaMusicaPreferida.updateUI();
    }

    private void quitarMusica() {
        Object[] musica = listaMusicaPreferida.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaMusica.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaMusicaPreferida.getModel();
        for(int i=0;i<musica.length;i++){
            dlm1.removeElement(musica[i]);
            dlm0.addElement(musica[i]);
        }
        listaMusica.updateUI();
        listaMusicaPreferida.updateUI();
    }

    private void agregarMedio() {
        Object[] medios = listaMedios.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaMedios.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaMediosPreferidos.getModel();
        for(int i=0;i<medios.length;i++){
            dlm0.removeElement(medios[i]);
            dlm1.addElement(medios[i]);
        }
        listaMedios.updateUI();
        listaMediosPreferidos.updateUI();
    }

    private void quitarMedio() {
        Object[] medios = listaMediosPreferidos.getSelectedValues();
        DefaultListModel dlm0 = (DefaultListModel)listaMedios.getModel();
        PreferenciaListModel dlm1 = (PreferenciaListModel)listaMediosPreferidos.getModel();
        for(int i=0;i<medios.length;i++){
            dlm1.removeElement(medios[i]);
            dlm0.addElement(medios[i]);
        }
        listaMedios.updateUI();
        listaMediosPreferidos.updateUI();
    }

    private void agregarAmigo() {
        gestor.agregarAmigo(
                textNombreAmigo.getText().trim(),
                textApellidoAmigo.getText().trim(),
                textTelefonoAmigo.getText().trim(),
                dateChooserAmigo.getDate());

        tableAmigos.updateUI();
        limpiarFormAmigo();
    }

    private void quitarAmigo() {
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Estas seguro que deseas borrar este amigo?", "Confirmacion", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_NO_OPTION);
        if(respuesta == JOptionPane.YES_OPTION){
            int row = this.tableAmigos.getSelectedRow();
            gestor.quitarAmigo(row);
        }

        tableAmigos.updateUI();
        limpiarFormAmigo();
    }

    private void limpiarFormAmigo(){
        textNombreAmigo.setText("");
        textApellidoAmigo.setText("");
        textTelefonoAmigo.setText("");
        dateChooserAmigo.setDate(null);
    }

}
